import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Stack;


public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int probNUmber = 1;
		while(true) {
			String str = br.readLine();
			if(str.contains("-")) {
				break;
			}
			int a = solve(str);
			System.out.println(probNUmber++ + ". " + a);
		}
	}
	
	private static int solve(String str) {
		Stack<Character> s = new Stack<Character>();
		int corrections = 0;
		for(int i = 0; i < str.length(); i++) {
			if(s.isEmpty()) {
				if(str.charAt(i) == '}') {
					corrections++;
				}
				s.push('{');
			} else {
				if(str.charAt(i) == '}') {
					s.pop();
				} else {
					s.push('{');
				}
			}
		}
		return corrections + s.size() / 2;
	}
	

}

